import Taro from "@tarojs/taro";
import {connect} from 'react-redux';
import {View, Text} from '@tarojs/components';
import {AtIcon, AtButton} from 'taro-ui';
import {Empty, Tag} from '@nutui/nutui-react-taro';
import Car from './carCard';
import './index.less'

function Cars(props) {
  const {dispatch, myCar} = props;
  console.log('myCar', myCar);
  return (
    <View className='carWrap'>
      {
        myCar && myCar.id ? <View>
          <View
              onClick={() => Taro.navigateTo({url: '/moduleB/pages/cars/add'})}
              style={{padding: '24rpx 0'}}
          ><Car car={myCar} /></View>
          <View className='pageFooter'>
            <View className='buttonInFooter'>
              <AtButton onClick={() => Taro.navigateTo({url: '/moduleB/pages/cars/add'})}>
                <AtIcon value='edit' size={18} /> 编辑车辆
              </AtButton>
            </View>
          </View>
        </View> : <View>
          <View className='walletWrap'>
            <Empty style={{backgroundColor: 'transparent', paddingTop: '100rpx'}} description='暂无车辆' />
          </View>
          <View className='walletFooter'>
            <View className='integralBtn'>
              <AtButton onClick={() => Taro.navigateTo({url: '/moduleB/pages/cars/add'})}>
                <AtIcon value='add' size={18} /> 添加车辆
              </AtButton>
            </View>
          </View>
        </View>
      }
    </View>
  )
}

function mapStateToProps({cars = {}}) {
  return {
    ...cars
  }
}

export default connect(mapStateToProps)(Cars)
